package com.company;

import com.company.test.Array;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public class Student implements Comparable<Student> {
    private String name;
    private int score;

    public Student(String name, int score) {
        this.name = name;
        this.score = score;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (this.getClass() != obj.getClass())
            return false;
        Student another = (Student) obj;
        return this.name.toLowerCase().equals(another.name.toLowerCase());
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, score);
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(@NotNull Student o) {
//        if (this.score < o.score)
//            return -1;
//        else if (this.score == o.score)
//            return 0;
//        return 1;
        return this.score - o.score;
    }

    public static void main(String[] args) {
        Array<Student> arr = new Array<>();
        arr.addLast(new Student("Sin", 100));
        arr.addLast(new Student("Bob", 66));
        arr.addLast(new Student("Car", 88));
        System.out.println(arr);
    }
}
